package com.fanco.learn_datastruct_leetcode.designpattern.mememto.game;

/**
 * @author qiaowang 2022/2/23
 * 描述
 */
public class GameRole {

    private int vit;

    private int def;

    // 创建一个 Memento,根据当前的状态 得到 Memento
    public Memento createMemento() {
        return new Memento(vit, def);
    }

    // 从备忘录对象 恢复 GameRole状态
    public void recoverGameRoleFromMemento (Memento memento) {
        this.vit = memento.getVit();
        this.def = memento.getDef();
    }

    // 显示当前游戏的状态
    public void display () {
        System.out.println("游戏角色当前的攻击力：" + this.vit);
        System.out.println("游戏角色当前的防御力：" + this.def);
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
